<?xml version='1.0' encoding='UTF-8' ?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml"
      xmlns:h="http://java.sun.com/jsf/html"
      xmlns:ui="http://java.sun.com/jsf/facelets"
      xmlns:f="http://java.sun.com/jsf/core"
      xmlns:p="http://primefaces.prime.com.tr/ui">
    <ui:composition template="/WEB-INF/facelets/template.xhtml">
        <ui:param name="title" value="Vrångö IF Gym – Mina Uppgifter" />
        <ui:define name="content">
            <h:form id="edit-form" enctype="image/jpeg" prependId="false">
                <h:panelGroup>
                    <h:panelGrid columns="4">
                        <h:outputLabel styleClass="edit-labels" for="editFirstName" value="Förnamn"/>
                        <p:inputText 
                            id="editFirstName"
                            value="#{Edit.firstname}"
                            styleClass="edit-input inputText"
                            />
                        <h:message for="editFirstName"/>
                        <p:fileUpload id="fileUploader" fileUploadListener="#{FileUpload.handleFileUpload}" allowTypes="*.jpg;*.png;*.gif" auto="true" description="Image" update="edit-form"/>
                        <h:message for="fileUploader"/>
                    </h:panelGrid>
                    <h:panelGrid columns="4">
                        <h:outputLabel styleClass="edit-labels" for="editLastName" value="Efternamn"/>
                        <p:inputText 
                            id="editLastName"
                            value="#{Edit.lastname}"
                            styleClass="edit-input inputText"
                            />
                        <h:message for="editLastName"/>
                        <h:outputLabel id="fileUploadLabel" styleClass="edit-labels" for="fileUploader" value="Ladda upp bild"/>
                    </h:panelGrid>
                    <h:panelGrid columns="3">
                        <h:outputLabel styleClass="edit-labels" for="editMail" value="Mailadress"/>
                        <p:inputText 
                            id="editMail"
                            value="#{Edit.mail}"
                            styleClass="edit-input inputText"
                            />
                        <h:message for="editMail"/>
                    </h:panelGrid>
                    <h:panelGrid columns="3">
                        <h:outputLabel styleClass="edit-labels" for="editPhone" value="Telefonnummer"/>
                        <p:inputText 
                            id="editPhone"
                            value="#{Edit.phone}"
                            styleClass="edit-input inputText"
                            />
                        <h:message for="editPhone"/>
                    </h:panelGrid>
                    <h:panelGrid columns="3">
                        <h:outputLabel styleClass="edit-labels" for="editStreet" value="Gatuadress"/>
                        <p:inputText 
                            id="editStreet"
                            value="#{Edit.street}"
                            styleClass="edit-input inputText"
                            />
                        <h:message for="editStreet"/>
                    </h:panelGrid>
                    <h:panelGrid columns="3">
                        <h:outputLabel styleClass="edit-labels" for="editZip" value="Postnummer"/>
                        <p:inputText 
                            id="editZip"
                            value="#{Edit.zipCode}"
                            styleClass="edit-input inputText"
                            />
                        <h:message for="editZip"/>
                    </h:panelGrid>
                    <h:panelGrid columns="3">
                        <h:outputLabel styleClass="edit-labels" for="editCity" value="Postort"/>
                        <p:inputText 
                            id="editCity"
                            value="#{Edit.city}"
                            styleClass="edit-input inputText"
                            />
                        <h:message for="editCity"/>
                    </h:panelGrid>
                    <h:panelGrid columns="3">
                        <h:outputLabel styleClass="edit-labels" for="editUserName" value="Användarnamn"/>
                        <p:inputText 
                            id="editUserName"
                            value="#{Edit.username}"
                            styleClass="edit-input inputText"
                            readonly="true"
                            />
                        <h:message for="editUserName"/>
                    </h:panelGrid>
                    <h:panelGrid columns="3">
                        <h:outputLabel styleClass="edit-labels" for="editPassword" value="Nytt Lösenord"/>
                        <p:password
                            feedback="false"
                            minLength="0"
                            id="editPassword"
                            value="#{Edit.newPassword}"
                            styleClass="edit-input inputText"
                            />
                        <p:message for="editPassword"/>
                    </h:panelGrid>
                    <h:panelGrid columns="3">
                        <h:outputLabel styleClass="edit-labels" for="editPassword2" value="Nytt Lösenord (igen)"/>
                        <p:password
                            feedback="false"
                            minLength="0" 
                            id="editPassword2"
                            value="#{Edit.newPassword2}"
                            styleClass="edit-input inputText"
                            />
                        <h:message for="editPassword2"/>
                    </h:panelGrid>
                    <h:panelGrid columns="3">
                        <h:outputLabel styleClass="edit-labels" for="editOldPassword" value="Gammalt Lösenord"/>
                        <p:password
                            feedback="false"
                            minLength="3" 
                            id="editOldPassword"
                            value="#{Edit.oldPassword}"
                            styleClass="edit-input inputText"
                            />
                        <h:message for="editOldPassword"/>
                    </h:panelGrid>
                    <h:panelGrid columns="3">
                        <h:outputLabel styleClass="edit-labels" for="avatar" value="Avatar"/>
                        <h:graphicImage id="avatar" library="images/avatars" name="#{Edit.username}" title="Avatar" alt="Avatar" />
                        <h:message for="avatar"/>
                    </h:panelGrid>
                    <h:panelGrid columns="3">


                    </h:panelGrid>
                    <p:commandButton actionListener="#{EditCtrl.edit}" 
                                     value="Uppdatera uppgifter" 
                                     action="onEdit"
                                     styleClass="commandButton" 
                                     update="edit-form"/>
                </h:panelGroup>
            </h:form>
        </ui:define>
    </ui:composition>
</html>
